<html>
<head><meta charset="utf-8"><title>Memory usage issue · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html">Memory usage issue</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="214177673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214177673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214177673">(Oct 22 2020 at 12:14)</a>:</h4>
<p>I just ran the memory usage command and it only freed up something like 400 MB. r-a is still consuming almost 2 GB of RAM after that. Has anyone seen this happen?</p>



<a name="214177969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214177969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214177969">(Oct 22 2020 at 12:17)</a>:</h4>
<p>No</p>



<a name="214177993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214177993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214177993">(Oct 22 2020 at 12:17)</a>:</h4>
<p>I think I saw the report that recent release increased memory usage for someone from 2GB to 4GB</p>



<a name="214178135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214178135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214178135">(Oct 22 2020 at 12:18)</a>:</h4>
<p>Could it be that freeing is run concurrently with prefetching, and it evens out to no-change?</p>



<a name="214178189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214178189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214178189">(Oct 22 2020 at 12:18)</a>:</h4>
<p>Probably makes sense to add a config flag to disable priming, it would be useulf in the futur to debug all kinds of issues</p>



<a name="214180603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214180603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214180603">(Oct 22 2020 at 12:41)</a>:</h4>
<p>Priming only happens once on startup</p>



<a name="214180693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214180693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214180693">(Oct 22 2020 at 12:42)</a>:</h4>
<p>Hm, maybe&amp;</p>



<a name="214180706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214180706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214180706">(Oct 22 2020 at 12:42)</a>:</h4>
<p>I would think the opposite</p>



<a name="214180802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214180802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214180802">(Oct 22 2020 at 12:43)</a>:</h4>
<p>We trigger it from <code>update_file_notifications_on_threadpool</code></p>



<a name="214180808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214180808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214180808">(Oct 22 2020 at 12:43)</a>:</h4>
<p>so, after every change</p>



<a name="214181364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214181364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214181364">(Oct 22 2020 at 12:48)</a>:</h4>
<p>Oh, right, nevermind me</p>



<a name="214524429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214524429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214524429">(Oct 26 2020 at 01:38)</a>:</h4>
<p>6.7 GB... this might be a problem</p>



<a name="214569640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214569640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214569640">(Oct 26 2020 at 13:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="211727">Jonas Schievink</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Memory.20usage.20issue/near/214177673">said</a>:</p>
<blockquote>
<p>I just ran the memory usage command and it only freed up something like 400 MB. r-a is still consuming almost 2 GB of RAM after that. Has anyone seen this happen?</p>
</blockquote>
<p>I've checked this again and it doesn't seem to be caused by cache priming. Computing memory usage twice in a row correctly yields 0mb across the board for the second run. RSS stays high, so that might be a different issue, or just weird allocator behavior.</p>
<p>When modifying a file, "indexing..." starts, RSS immediately goes down by a lot, and then slowly grows back to where it was before.</p>



<a name="214569828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214569828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214569828">(Oct 26 2020 at 13:04)</a>:</h4>
<p><span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> have zero idea about what might be the issue. The best I can suggest is dropping things one by one and noting when it floats :)</p>



<a name="214570222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214570222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214570222">(Oct 26 2020 at 13:06)</a>:</h4>
<p>I'll try with mimalloc</p>



<a name="214570282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214570282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214570282">(Oct 26 2020 at 13:07)</a>:</h4>
<p>Does <code>massif</code> work?</p>



<a name="214570329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214570329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214570329">(Oct 26 2020 at 13:07)</a>:</h4>
<p>Yes, but it's excruciatingly slow</p>



<a name="214570379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214570379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214570379">(Oct 26 2020 at 13:08)</a>:</h4>
<p>so i'd rather avoid it</p>



<a name="214570892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214570892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214570892">(Oct 26 2020 at 13:12)</a>:</h4>
<p>mimalloc behaves the same way, but is less memory efficient</p>



<a name="214571397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214571397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214571397">(Oct 26 2020 at 13:17)</a>:</h4>
<div class="codehilite"><pre><span></span><code>Inference: 23.91s, 115428mi
Total: 36.84s, 206986mi
</code></pre></div>


<p>???</p>



<a name="214571507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214571507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214571507">(Oct 26 2020 at 13:18)</a>:</h4>
<p>TBH, I don't remmeber if those are diffs or totals</p>



<a name="214571511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214571511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214571511">(Oct 26 2020 at 13:18)</a>:</h4>
<p>Oh, that's million instructions, not megabytes of RAM</p>



<a name="214571544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214571544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214571544">(Oct 26 2020 at 13:18)</a>:</h4>
<p>and yes, that as well</p>



<a name="214571644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214571644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214571644">(Oct 26 2020 at 13:19)</a>:</h4>
<p>We still use some 1.2-1.3 GB on RA itself, that's maybe a bit much?</p>



<a name="214577323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214577323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214577323">(Oct 26 2020 at 14:06)</a>:</h4>
<div class="codehilite"><pre><span></span><code>Inference: 41.06ms, 96mi, -57kb
Total: 30.17s, 100352mi, 1225mb
</code></pre></div>


<p>-57kb????</p>



<a name="214577731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214577731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214577731">(Oct 26 2020 at 14:09)</a>:</h4>
<p>Oh, it's just a diff, that seems confusing</p>



<a name="214577754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Memory%20usage%20issue/near/214577754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Memory.20usage.20issue.html#214577754">(Oct 26 2020 at 14:09)</a>:</h4>
<p>Looks like we <em>actually</em> use around 1.4G</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>